package com.plian.system.entity.lg;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.plian.Tools.DateUtil;
import com.plian.system.mybatis.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 法律纠纷
 * </p>
 *
 * @author hu song
 * @since 2023-01-30
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("lg_law_dispute")
@ApiModel(value="LawDispute对象", description="法律纠纷")
public class LawDispute extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @JsonSerialize(using = ToStringSerializer.class)
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键id")
    @NotNull(groups = Update.class)
    @Null(groups = Save.class)
    private Long id;

    @ApiModelProperty(value = "单据编码")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String code;

    @ApiModelProperty(value = "填报单位")
    @NotEmpty
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String fillingUnitId;

    @ApiModelProperty(value = "单位")
    @NotEmpty
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String unitId;

    @ApiModelProperty(value = "发生时间")
    @DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
    @JsonFormat(pattern = DateUtil.PATTERN_DATE, timezone = "Asia/Shanghai")
    @NotNull
    private Date happenTime;

    @ApiModelProperty(value = "涉案金额(万元)")
    @NotNull
    private BigDecimal amountInvolved;

    @ApiModelProperty(value = "案件类型 149001:担保类;149002:合同类;149003:权属纠纷类;149004:劳动纠纷类:149005:其他")
    @NotEmpty
    private String caseType;

    @ApiModelProperty(value = "案情焦点及争议")
    @NotNull
    private String caseFocusAndDispute;

    @ApiModelProperty(value = "年度id 115001:上半年;115002:下半年")
    private String timeSpanId;

    @ApiModelProperty(value = "处理措施和结果")
    @NotNull
    private String treatmentMeasuresAndResults;

    @ApiModelProperty(value = "填表人")
    @NotNull
    private String fillingBy;

    @ApiModelProperty(value = "联系电话")
    @NotNull
    private String contactNumber;

    @ApiModelProperty(value = "备注")
    @NotNull
    private String remark;

    @ApiModelProperty(value = "审批人")
    private String approvedUser;

    @ApiModelProperty(value = "审批时间")
    @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME, timezone = "Asia/Shanghai")
    private Date approvedTime;

    @ApiModelProperty(value = "审批意见")
    private String approvedOpinion;

    @ApiModelProperty(value = "流程实例id")
    private String formType;

    @ApiModelProperty(value = "经济损失类型 150001:挽回经济损失;150002:造成经济损失")
    private String economicLossType;

    @ApiModelProperty(value = "损失金额(万元)")
    private BigDecimal amount;

    @ApiModelProperty(value = "是否胜诉")
    private Boolean isWin;

    @ApiModelProperty("当事人列表")
    @TableField(exist = false)
    @NotNull(message = "当事人信息不能为空")
    private List<LawDisputeUser> lawDisputeUsers;

    @ApiModelProperty("案例追踪列表")
    @TableField(exist = false)
    @NotNull(message = "案件信息不能为空")
    private List<LawDisputeCaseTracing> lawDisputeCaseTracings;

    @TableField(exist = false)
    @ApiModelProperty("案件状态")
    private String caseStatus;

    @ApiModelProperty(value = "数据来源 null为系统填报 对应用户id")
    private String dataSource;

    @ApiModelProperty(value = "数据来源id", required = true)
    private String dataSourceId;

    @TableField(exist = false)
    @ApiModelProperty(value = "启动流程标志",hidden = true)
    private Boolean startFlowFlag = true;

    public @interface Save{}
    public @interface Update{}
}
